package com.ksc.storekeeper.client.view.components;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

public class EachItemDisplay extends Composite {

	private static EachItemDisplayUiBinder uiBinder = GWT.create(EachItemDisplayUiBinder.class);

	interface EachItemDisplayUiBinder extends UiBinder<Widget, EachItemDisplay> {
	}
	
	@UiField
	Label productId;
	
	@UiField
	Image productImage;
	
	@UiField
	Label productName;
	
	@UiField
	Label productPrice;
	
	@UiField
	Button productShowBtn;
	
	public EachItemDisplay() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	public EachItemDisplay(Long id,String name,String imgUrl,String price,ClickHandler handler) {
		initWidget(uiBinder.createAndBindUi(this));
		productId.setText(id==null?"NO_ID":id.toString());
		productImage.setUrl(imgUrl==""?"/images/product/nophoto.png":"images/product/"+imgUrl);
		productName.setText(name);
		productPrice.setText(price);
		productShowBtn.addClickHandler(handler);
	}

}
